<template>
  <div class="all">
    <header >
      <div class="div" @click="back">
        <img src="../../assets/返回.png" alt="">
        <span>返回</span>
      </div>
      <div class="div">
        <span>健康服务签约</span>
      </div>
      <div class="div"></div>
    </header>
        <ul class="ulList" v-for="(item, index) in titleList"
              :key="index"
              @click="jump(item.url, item.title, item.dict_value)">
            <li class="li" >
              <img  :src="require('../../assets/' + item.img + '@2x.png')" class="img" alt="">
              <span>
                <a style="height: 60px;line-height: 60px">{{item.title}}</a>
                <a  style="color: #999;margin-left: 5px"> {{item.count > 0 ? item.count : ''}}</a>
              </span>
            </li>
            <li class="more">
              <img src="../../assets/更多灰@2x.png" alt="">
            </li>
          </ul>
    <van-loading v-show="isLoading" size="24px" style="width: 100%;height: 80vh;
    display:flex;align-items:center;justify-content:center; color: #1da4f2" vertical>
      加载中...
    </van-loading>
  </div>
</template>

<script>
export default {
  name: 'Doctor',
  data () {
    return {
      titleList: [],
      userid: '',
      isLoading: true
    }
  },
  mounted () {
    // 截取网址后的userid
    this.userid = this.$utils.getUrlKey('userid')
    // 获取列表
    this.getList()
    // $('.content').css('height', $(window).height() - $('header').height() - 50 + 'px')
  },
  methods: {
    // 获取列表
    getList () {
      this.isLoading = true
      this.$http.jiankangServiceList({'user_id': this.userid})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            for (var i = 0; i < res.data.data.length; i++) {
              var obj = {
                'title': res.data.data[i].dict_name,
                'id': res.data.data[i].id,
                'count': res.data.data[i].count,
                'img': res.data.data[i].dict_name,
                'dict_value': res.data.data[i].dict_value
              }
              this.titleList.push(obj)
            }
            this.isLoading = false
          } else {
            this.isLoading = false
          }
        })
        .catch(err => {
          this.isLoading = false
          console.log(err)
        })
    },
    // 点击跳转
    jump (url, title, type) {
      window.sessionStorage.removeItem('menuIndex')
      this.$router.push({path: '/healthSign', query: {'userid': this.userid, 'title': title, 'type': type}})
    },
    // 返回
    back () {
      this.$router.history.go(-1)
    }
  }
}
</script>

<style scoped>
  .all{
    width: 100%;
    height: 100%;
    background: #FAF9FE;
    overflow: auto;
  }
  header{
    width: 100%;
    display: flex;
    height: 12vw;
    align-items: center;
    background: #FFFFFF;
    position: sticky;
    top: 0;
    z-index: 99;
    border-bottom: 1px solid #ebedf0;
  }
  header .div{
    width: 33%;
    display: flex;
    align-items: center;
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: bold;
  }
  header .div img{
    width: 7px;
    height: 13px;
    margin-left: 15px;
    margin-right: 5px;
  }
  header .div:nth-child(1){
    color: #1da4f2;
  }
  header .div:nth-child(2){
    color: #333333;
    justify-content: center;
  }
  /deep/ .van-cell{
    padding: 12px 16px;
    font-size: 15px;
    box-sizing: border-box;
  }
  .content{
    width: 100%;
    overflow: auto;
  }
  .all .ulList:last-child{
    margin-bottom: 10px;
  }
  .ulList{
    width: 92%;
    height: 60px;
    background: #FFFFFF;
    border-radius: 10px;
    display: flex;
    align-items: center;
    padding: 13px 15px;
    box-sizing: border-box;
    background: #FFFFFF;
    margin: 10px auto;
  }
  .ulList:last-child{
    margin-bottom: 5px;
  }
  .more img{
    width: 7px;
    height: 13px;
  }
  .li{
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    font-family: PingFang SC;
    font-weight: 500;
  }
  .li span{
    /*display: block;*/
    height: 100%;
    display: flex;
    align-items: center;
  }
  .img{
    width: 18px;
    height: 18px;
    margin: 0 10px 0 5px;
  }
</style>
